/****************************************************************************
 * Copyright (c) 2010 Torkild U. Resheim
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Torkild U. Resheim  - initial API and implementation
 *****************************************************************************/
package no.resheim.buildmonitor.ui.views.commands;

import no.resheim.buildmonitor.core.data.Job;

import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;

/**
 * Command handler for starting a build of the selected job.
 * 
 * @author Torkild Ulvøy Resheim
 * @since 1.0
 */
public class StartBuildHandler extends AbstractCommandHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		Object obj = getSelection(event);
		if (obj != null && obj instanceof Job) {
			((Job) obj).build();
		}
		return null;
	}

}
